<script setup lang="ts">
import { OrderTypeVO, listOrderType} from '@/views/wms/order/api';

const pd = reactive({
  typeList: <OrderTypeVO[]>([]),
  queryParams: <OrderTypeVO>{
    pageNum: 1,
    pageSize: 10},
});

// 声明外部传入的数据
const props = defineProps({
  typeId: {type: Number, default: ''},
  params: {type: Object, default: null}
});
// 定义需要回传的数据
const emits = defineEmits(["update:typeId"]);

const typeData = computed({
  get() {
    return props.typeId
  },
  set(val) {
    emits("update:typeId", val)
  }
})
function getList(){
  pd.queryParams = {...pd.queryParams, ...props.params};
  listOrderType(pd.queryParams).then(res =>{
    pd.typeList = res.rows;
  })
}
onMounted(() => {
  getList();
})
</script>

<template>
  <el-select v-model="typeData" clearable>
    <el-option v-for="item in pd.typeList" :key="item.typeId" :label="item.name" :value="item.typeId!"/>
  </el-select>
</template>
